class SysadminController < ApplicationController
	before_filter :login_required
	layout "framework"
	def index
		@session[:rights] = buildMenu '系统管理'
	end
  	
  	def varadmin
  		if !request.get?
  			var = ConfigVariable.find_by_name 'myname'
  			var.value = params[:myname]
  			var.save
  			var = ConfigVariable.find_by_name 'myaddress'
  			var.value = params[:myaddress]
  			var.save
  			var = ConfigVariable.find_by_name 'myphone'
  			var.value = params[:myphone]
  			var.save
  			var = ConfigVariable.find_by_name 'myfax'
  			var.value = params[:myfax]
  			var.save
  			var = ConfigVariable.find_by_name 'myaddress1'
  			var.value = params[:myaddress1]
  			var.save
  			var = ConfigVariable.find_by_name 'myphone1'
  			var.value = params[:myphone1]
  			var.save
  			var = ConfigVariable.find_by_name 'myfax1'
  			var.value = params[:myfax1]
  			var.save
  			flash[:notice] = "<img src='/images/ok.gif'><font color='green'>公司信息已经成功修改！</font>"
  		end
  		vars = ConfigVariable.find_all
  		vars.each do |var|
  			@myname=var.value if var.name.eql? 'myname'
  			@myaddress=var.value if var.name.eql? 'myaddress'
  			@myphone=var.value if var.name.eql? 'myphone'
  			@myfax=var.value if var.name.eql? 'myfax'
  			@myaddress1=var.value if var.name.eql? 'myaddress1'
  			@myphone1=var.value if var.name.eql? 'myphone1'
  			@myfax1=var.value if var.name.eql? 'myfax1'
  		end
  	end
end
